#!/bin/bash
set -euo pipefail
BaseDir=$(cd "$(dirname "$0")"; pwd)
cd ${BaseDir}

docker build -t openeuler:24.03-lts_libreoffice24 .

#这里实验好错误的地方，将命令修订到Dockerfile中,再次构建镜像
echo "测试下镜像，exit 可以退出"
docker run -it --rm --name tmpoffice openeuler:24.03-lts_libreoffice24 bash

cat <<EOF
测试中文和libreoffice的功能

docker cp test.docx tmpoffice:/opt/
docker exec -it tmpoffice bash -c "echo test; /opt/libreoffice24.8/program/soffice --headless --convert-to pdf /opt/test.docx --outdir /opt/"
rm -f ./test.pdf ||true
docker cp tmpoffice:/opt/test.pdf ./
EOF

